{extend name="user-layout" /}
{block name="content"}

<div class="content-wrapper">
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">新增账户</h4>
                    <form class="layui-form forms-sample" action="" method="post">
                        <input name="b[uid]" value="{$user_info.uid}" hidden disabled readonly >
                        <input type="text" hidden disabled name="b[scene]" value="add">
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">选择银行</label>
                            <div class="col-sm-9">
                                <select name="b[banker]" required lay-verify="required" class="form-control">
                                    <option value="">选择收款账户</option>
                                    {volist name="banker" id="vo"}
                                    <option value="{$vo.id}" {$vo.default ? 'selected':''}>{$vo.name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">账号</label>
                            <div class="col-sm-9">
                                <input type="text" name="b[account]" value="" required lay-verify="required" class="form-control" placeholder="输入账号">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">开户地址</label>
                            <div class="col-sm-9">
                                <input type="text" name="b[address]" value="" required lay-verify="required" class="form-control" placeholder="开户地址">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">手机验证码</label>
                            <div class="col-sm-9">
                                <div class="input-group col-xs-12">
                                    <input type="text" name="b[vercode]" required lay-verify="required" maxlength="6" class="form-control file-upload-info" placeholder="手机验证码">
                                    <span class="input-group-append">
                                        <button type="button" id="sendVerCode" class="file-upload-browse btn-show-vercode btn btn-primary">发送</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">备注</label>
                            <div class="col-sm-9">
                                <textarea type="text" name="b[remarks]" class="form-control" rows="3"></textarea>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-primary btn-account-submit btn-fw" lay-submit lay-filter="app-user-account-submit">提交修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="pagejs"}
<script src="__STATIC__/common/layui/layui.js"></script>
<script>
    layui.use(['form'], function(){
        let $ = layui.$
            ,form = layui.form
            , verBtn = $("#sendVerCode")
            , countdown = 60; // 验证码限制时间

        //监听搜索
        form.on('submit(app-user-account-submit)', function(data){
            let field = data.field;
            console.log(field)
            //提交
            $.ajax({
                url:'{:url(\'index/Balance/addAccount\')}',
                method:"POST",
                data:field, success:function (res) {
                    if (res.code == 1){
                        setTimeout(
                            location.href = '{:url(\'index/Balance/account\')}'
                        ,1000);
                    }
                    showToast(res);
                }
            });
        });
    });
</script>
{/block}
